package com.itheima.fanshe3;

import java.lang.reflect.Method;

/*
用反射 获取方法对象
 */
public class Demo01 {


    public static void main(String[] args) throws Exception {
   /*     Singer singer = new Singer();
        Class<? extends Singer> clazz = singer.getClass();*/
        Class clazz = Class.forName("com.itheima.fanshe3.Singer");

        Method[] methods = clazz.getMethods();
        for (Method method : methods) {
            System.out.println(method);
        }

        System.out.println("==============");
        Method[] declaredMethods = clazz.getDeclaredMethods();
        for (Method declaredMethod : declaredMethods) {
            System.out.println(declaredMethod);
        }
        System.out.println("==============");
        Method sing = clazz.getMethod("sing");
        System.out.println(sing);
        Method dance = clazz.getMethod("dance", String.class);
        System.out.println(dance);

        Method rap = clazz.getMethod("rap");
        System.out.println(rap);
        Method basketball = clazz.getMethod("basketball", int.class,int.class);
        System.out.println(basketball);

        Method show = clazz.getDeclaredMethod("show");
        System.out.println(show);
        Method use = clazz.getDeclaredMethod("use", String.class);
        System.out.println(use);

    }

}
